'''
Pareto分布
概率密度函数图像
'''

import matplotlib.pyplot as plt
import numpy as np
from pylab import mpl
plt.style.use('seaborn-darkgrid')
mpl.rcParams['font.sans-serif'] = ['SimHei']  # 显示中文字体
plt.rcParams['axes.unicode_minus'] = False  # 显示负号

x = np.linspace(-3, 3, 500)
ls = [0., -2]
us = [2., 1]
for l, u in zip(ls, us):
    y = np.zeros(500)
    y[(x < u) & (x > l)] = 1.0 / (u - l)
    plt.plot(x, y, label='a = {}, b = {}'.format(l, u))
plt.xlabel('x', fontsize=12)
plt.ylabel('f(x)', fontsize=12)
plt.ylim(0, 1)
plt.legend(loc=1)
plt.title("均匀分布——不同参数的概率密度函数")
plt.show()